# This is script for MySQL to 
# create database structure for UdmSearch 3.2.x
# use: "mysql database <create.txt"
#


#DROP TABLE url;
#DROP TABLE urlinfo;
#DROP TABLE robots;
#DROP TABLE dict;
#DROP TABLE ndict;
#DROP TABLE crossdict;
#DROP TABLE ncrossdict;
#DROP TABLE categories;
#DROP TABLE qtrack;



CREATE TABLE url (
  rec_id int(11) DEFAULT '0' NOT NULL auto_increment,
  status smallint(6) DEFAULT '0' NOT NULL,
  url char(128) binary DEFAULT '' NOT NULL,
  content_type char(48) DEFAULT '' NOT NULL,
  docsize int(11) DEFAULT '0' NOT NULL,
  next_index_time INT NOT NULL,
  last_mod_time INT NOT NULL,
  referrer int(11) DEFAULT '0' NOT NULL,
  tag char(16) DEFAULT '0' NOT NULL,
  hops smallint(6) DEFAULT '0' NOT NULL,
  category char(16) DEFAULT '' NOT NULL,
  crc32 int(11) DEFAULT '0' NOT NULL,
  lang char(32) DEFAULT '' NOT NULL,
  charset char(40) DEFAULT '' NOT NULL,
  seed smallint(6) DEFAULT '0' NOT NULL,
  bad_since_time INT NOT NULL,
  PRIMARY KEY (rec_id),
  UNIQUE url (url),
  KEY key_crc (crc32),
  KEY key_seed (seed),
  KEY key_referrer (referrer),
  KEY key_bad_since_time (bad_since_time),
  KEY key_next_index_time (next_index_time)
);

CREATE TABLE urlinfo (
  url_id INT         NOT NULL,
  sname  VARCHAR(32) NOT NULL,
  sval   TEXT        NOT NULL,
  KEY    urlinfo_id  (url_id)
);


CREATE TABLE dict (
  url_id int(11) DEFAULT '0' NOT NULL,
  word varchar(32) DEFAULT '' NOT NULL,
  intag int(11) DEFAULT '0' NOT NULL,
  KEY url_id (url_id),
  KEY word_url (word)
);


CREATE TABLE robots (
  hostinfo varchar(127) DEFAULT '' NOT NULL,
  path varchar(127) DEFAULT '' NOT NULL
);


CREATE TABLE categories (
  rec_id int(11) DEFAULT '0' NOT NULL auto_increment,
  path char(10) DEFAULT '' NOT NULL,
  link char(10) DEFAULT '' NOT NULL,
  name char(64) DEFAULT '' NOT NULL,
  PRIMARY KEY (rec_id)
);



CREATE TABLE qtrack (
  qwords  varchar(63) DEFAULT '' NOT NULL,
  ip      varchar(16) DEFAULT '' NOT NULL,
  qtime   int(11) DEFAULT '0' NOT NULL,
  found   int(11) DEFAULT '0' NOT NULL,
  ps int(11) DEFAULT '' NOT NULL,
  np int(11) DEFAULT '' NOT NULL,
  m varchar(63) DEFAULT '' NOT NULL,
  wm varchar(63) DEFAULT '' NOT NULL,
  o int(11) DEFAULT '' NOT NULL,
  t varchar(63) DEFAULT '' NOT NULL,
  cat varchar(63) DEFAULT '' NOT NULL,
  ul varchar(63) DEFAULT '' NOT NULL,
  wf varchar(63) DEFAULT '' NOT NULL,
  g varchar(63) DEFAULT '' NOT NULL,
  tmplt varchar(63) DEFAULT '' NOT NULL
);



CREATE TABLE crossdict (
  url_id int(11) DEFAULT '0' NOT NULL,
  ref_id int(11) DEFAULT '0' NOT NULL,
  word  varchar (32) DEFAULT '0' NOT NULL,
  intag  int(11) DEFAULT '0' NOT NULL,
  KEY url_id (url_id),
  KEY ref_id (ref_id),
  KEY word (word)
);


CREATE TABLE ncrossdict (
  url_id int(11) DEFAULT '0' NOT NULL,
  ref_id int(11) DEFAULT '0' NOT NULL,
  word_id int(11) DEFAULT '0' NOT NULL,
  intag  int(11) DEFAULT '0' NOT NULL,
  KEY url_id (url_id),
  KEY ref_id (ref_id),
  KEY word_id (word_id)
);


CREATE TABLE ndict (
  url_id int(11) DEFAULT '0' NOT NULL,
  word_id int(11) DEFAULT '0' NOT NULL,
  intag int(11) DEFAULT '0' NOT NULL,
  KEY url_id (url_id),
  KEY word_id (word_id)
);
